package cn.itcast.user.web;

import cn.itcast.user.pojo.User;
import cn.itcast.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     * 路径： /user/110
     */
    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") Long id) {
        if (id == 1) {
            throw new RuntimeException("故意抛出异常，测试异常比例熔断");
        }
        return userService.queryById(id);
    }
}
